home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / STREAMS / ENCRYPT.PAS < prev    next >
Pascal/Delphi Source File  |  1996-07-22  |  2KB  |  39 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; encryption filter with file streams
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBIO;
  10.  
  11. const EncryptionBuffer = 4096;
  12.  
  13. var Source, Target : StreamObjectPointerType;
  14.  
  15. { ParamStr(1) must contain the input file, ParamStr(2) the output
  16.   file and ParamStr(3) your keyword string. }
  17.  
  18. begin
  19.      { Initialize source stream }
  20.      Source := New (FileStreamObjectPointerType,
  21.                     Initialize (ParamStr(1), EncryptionBuffer));
  22.  
  23.      { Initialize target stream as a filtered stream based on the
  24.        encryption filter with a file stream as secondary stream. }
  25.      Target := New (EncryptFilterObjectPointerType,
  26.                     Initialize (ParamStr(3), New (FileStreamObjectPointerType,
  27.                                 { Keyword }  { Base stream (will be intercepted) }
  28.                     Initialize (ParamStr(2), EncryptionBuffer))));
  29.                                 { Filename } { Buffer size }
  30.  
  31.      { Demonstrate seeking inside an filtered, encrypted stream }
  32.      Target^.Seek(Target^.Size div 2); Target^.Seek(0);
  33.  
  34.      { Transfer all data from source to the target (the target is
  35.        the secondary stream inside the encryption filter. }
  36.      Source^.MoveOut (Target, Source^.Size);
  37.  
  38.      Source^.Free; Target^.Free;
  39. end.